#include "rfid_common.h"

void reverse_data (void *buf, int len)
{
	uint8_t* head = buf;
	uint8_t* tail = (uint8_t *)buf + len - 1;
	uint8_t tmp;
	
	if(len == 0) return ;
	
	while(head < tail)
	{
		tmp = *head;  
		*head++ = *tail;
		*tail-- = tmp;
	}
}

uint16_t compute_average_adc_value(uint16_t *buf, uint32_t len)
{
	uint32_t value = 0;
	for(uint32_t i=0;i<len;i++)
	{
		value += buf[i];
	}
	return value / len;
}

uint8_t compute_average_time_value(uint8_t *time, uint32_t len)
{
	uint32_t value = 0;
	for(uint32_t i=0;i<len;i++)
	{
		value += time[i];
	}
	return value / len;
}
